package collection.listtest;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class ListDemo {
    public static void main(String[] args) {
        List<Integer> list= new ArrayList<>();
        list.add(12);
        list.add(1);
        list.add(34);
        list.add(67);
        System.out.println(list);
        System.out.println(list.get(2));
        System.out.println("------");
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }
        for (Integer in:list){
            System.out.println(in);
        }

        Iterator<Integer> it = list.iterator();
        while (it.hasNext()){
            System.out.println(it.next());
        }
        System.out.println("--------");
        list.set(2,40);
        System.out.println("list修改后："+list);

        list.add(0,185);
        System.out.println("list插入后数据："+list);

        list.remove(4);
        System.out.println("list删除后数据："+list);

    }
}
